home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / ubppmpqs.zip / ppmp2a.asm < prev    next >
Assembly Source File  |  1992-05-10  |  2KB  |  178 lines

  1. ;PPMP2A.ASM 1.0
  2. ;    MACHINE LANGUAGE SUBROUTINES
  3. ;    FOR PPMPQS
  4. ;    1991 by YUJI KIDA
  5. ;
  6. .386P
  7.  
  8. code    segment    use16
  9.     assume cs:code,ds:code
  10.  
  11.  
  12.     INCLUDE    UBP.MAC
  13.  
  14. open    macro    fname
  15.     mov    ah,3dh
  16.     mov    al,2
  17.     mov    dx,offset fname
  18.     int    21h
  19. endm
  20.  
  21.     org    100h
  22. start:
  23.     JMP    START0
  24.  
  25. even
  26. handle1    dw    ?
  27. handle2    dw    ?
  28.  
  29.  
  30. F1    db    32 dup(?)
  31. F2    db    'PPMP-F.UBD',0
  32. P1    db    32 dup(?)
  33. P2    db    'PPMP-P.UBD',0
  34. PP1    db    32 dup(?)
  35. PP2    db    'PPMP-PP.UBD',0
  36. F1name    db    'PPMP-F.UBD',0
  37. P1name    db    'PPMP-P.UBD',0
  38. PP1name    db    'PPMP-PP.UBD',0
  39.  
  40. start0:
  41.     mov    ax,cs
  42.     mov    ds,ax
  43.     mov    es,ax
  44.  
  45.     mov    bx,V1
  46.     lds    si,[bx]
  47.     lodsw
  48.     and    ax,81ffh    ;cut types
  49.     shl    ax,1
  50.     sbb    ax,0
  51.     mov    cx,ax
  52.  
  53.     push    cx
  54.     mov    di,offset F1
  55.     rep    movsb
  56.     mov    ax,cs
  57.     mov    ds,ax
  58.     mov    si,offset F1name
  59.     mov    cx,16
  60.     rep    movsb
  61.  
  62.     pop    cx
  63.     push    cx
  64.     mov    si,offset F1
  65.     mov    di,offset P1
  66.     rep    movsb
  67.     mov    si,offset P1name
  68.     mov    cx,16
  69.     rep    movsb
  70.  
  71.     pop    cx
  72.     mov    si,offset F1
  73.     mov    di,offset PP1
  74.     rep    movsb
  75.     mov    si,offset PP1name
  76.     mov    cx,16
  77.     rep    movsb
  78.  
  79.     open    F1
  80.     mov    [handle1],ax
  81.     open    F2
  82.  
  83.     mov    [handle2],ax
  84.     call    copy
  85.     jc    errorret
  86.  
  87.     open    P1
  88.     mov    [handle1],ax
  89.     open    P2
  90.  
  91.     mov    [handle2],ax
  92.     call    copy
  93.     jc    errorret
  94.  
  95.     open    PP1
  96.     mov    [handle1],ax
  97.     open    PP2
  98.  
  99.     mov    [handle2],ax
  100.     call    copy
  101.     jc    errorret
  102. retout:
  103.     mov    ax,ss
  104.     mov    ds,ax
  105.     mov    es,ax
  106.     retf
  107.  
  108. errorret:
  109.     mov    bx,AR0
  110.     mov    word ptr [bx],8001h    ;set -1 for error code
  111.     jmp    retout
  112.  
  113. copy:
  114.     mov    ah,42h        ;move file ptr
  115.     mov    al,0
  116.     mov    bx,[handle1]
  117.     xor    cx,cx
  118.     mov    dx,16        ;skip header
  119.     int    21h
  120.  
  121.     mov    ah,42h        ;move file ptr
  122.     mov    al,2
  123.     mov    bx,[handle2]
  124.     xor    cx,cx
  125.     xor    dx,dx        ;move to file end
  126.     int    21h
  127.  
  128. appendlp:
  129.     mov    ah,3fh        ;read
  130.     mov    dx,offset buffer
  131.     mov    cx,8000h
  132.     mov    bx,[handle1]
  133.     int    21h
  134.     jc    appenderror
  135.  
  136.     mov    cx,ax
  137.     mov    ah,40h        ;write
  138.     mov    dx,offset buffer
  139.     mov    bx,[handle2]
  140.     int    21h
  141.     jc    appenderror
  142.  
  143.     cmp    ax,cx
  144.     jne    appenderror
  145.  
  146.     cmp    ax,8000h
  147.     je    appendlp
  148.  
  149.     mov    ah,3eh
  150.     mov    bx,[handle1]
  151.     int    21h
  152.  
  153.     mov    ah,3eh
  154.     mov    bx,[handle2]
  155.     int    21h
  156.  
  157.     clc
  158.     ret
  159.  
  160. appenderror:
  161.     mov    ah,3eh
  162.     mov    bx,[handle1]
  163.     int    21h
  164.  
  165.     mov    ah,3eh
  166.     mov    bx,[handle2]
  167.     int    21h
  168.  
  169.     stc
  170.     ret
  171.         
  172.  
  173. even
  174. buffer    db    8000h dup(0)
  175.     
  176. code    ends
  177. end    start
  178.